% cover-createspace-quarto.tex

% make a cover PDF for KDP Crown Quarto booksize.
\pdfminorversion=4
\documentclass{memoir}

\newcommand{\olpath}{../../}

\usepackage[absolute,overlay]{textpos}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage{forallxyyc}

\usepackage{helvet}

\newlength{\coverheight}
\newlength{\coverwidth}
\newlength{\spinewidth}
\newlength{\spinepos} % spine starts here, width = \spinewidth
\newlength{\coverpos} % front cover starts here, width = \spinepos
\newlength{\sheetwidth}
\setlength{\sheetwidth}{0.002252in}

\setlength{\coverheight}{9.69in}  % trim height
\setlength{\spinepos}{7.44in} % trim width
\setlength{\spinewidth}{399\sheetwidth}

% compute actual widths
\addtolength{\coverheight}{.25in} % add bleed
\addtolength{\spinepos}{.125in} % adjust for bleed
\setlength{\coverwidth}{\spinepos}
\addtolength{\coverwidth}{\coverwidth}
\addtolength{\coverwidth}{\spinewidth}

\newlength{\coverartpos}
\setlength{\coverartpos}{-1in}
\addtolength{\coverartpos}{\spinewidth}

% \coverpos = \spinepso + \spinewidth
\setlength{\coverpos}{\spinepos}
\addtolength{\coverpos}{\spinewidth}

% set stock size to total width & height of cover 
\setstocksize{\coverheight}{\coverwidth}

% pagesize = stocksize
\settrimmedsize{\stockheight}{\stockwidth}{*}
\settrims{0pt}{0pt}

% no margins or headers
\setlrmarginsandblock{0pt}{0pt}{*}
\setheadfoot{0pt}{0pt}
\setulmarginsandblock{0pt}{0pt}{*}
\setheadfoot{0pt}{0pt}
\setlength{\headsep}{0pt}


% finalize the page layout
\checkandfixthelayout[fixed]
\typeoutlayout

\color{black}

%\usepackage[x-1a]{pdfx}

\begin{document}

\sffamily

\definecolor{lyallpink}{RGB}{222,31,149}
% no folios
\pagestyle{empty}

\begin{textblock*}{\coverwidth}(\coverartpos,3.646in)
  \noindent\includegraphics{assets/forallx-coverart-full.pdf}
\end{textblock*}

% make a spine
\begin{textblock*}{\spinewidth}(\spinepos,0bp)%
  \noindent\hfil
  \rotatebox{-90}{% make spine text readable when book is lying cover up
    \hbox to \coverheight{
      \hskip 1.5cm
      \fontsize{16pt}{19pt}\sffamily\bfseries\selectfont
      \color{black}
      forall x: Calgary\hfil
      \color{white}
      \forallxshortversion\hspace{1.1cm}}}%
  \hfil
\end{textblock*}
\newbox\adjust

% make front cover
\begin{textblock*}{\spinepos}(\coverpos,0pt)
  \noindent\hfill
  \begin{minipage}[b][\coverheight][s]{.8\spinepos}
    \begin{raggedleft}
      \vspace*{1.7cm}
      \hfill
      \sffamily\fontsize{87pt}{0pt}\selectfont
      \color{lyallpink}
      \textbf{forall}%
      \fontsize{110pt}{0pt}\selectfont\rmfamily\textit{\textbf{x}\/}
                    
      \vskip.5cm
          
      \sffamily\fontsize{32pt}{0pt}\selectfont
      \color{black}
      \textbf{\uppercase{Calgary}}

      \vspace*{1cm}
      \color{black}
      \sffamily
      \fontsize{25pt}{25pt}\selectfont
      \textbf{An Introduction to\\ Formal Logic}

      \vfill
      \fontsize{16pt}{19pt}\selectfont
      \color{white}
      \textbf{P.~D. Magnus}\\
      \textbf{Tim Button}\\
      \textit{with additions by}\\
      \textbf{J.~Robert Loftis}\\
      \textbf{Robert Trueman}\\
      \textit{remixed and revised by}\\
      \textbf{Aaron Thomas-Bolduc}\\ \textbf{Richard Zach}\par
      \vspace{1.2cm}
      \textbf{\forallxversion}\par
      \vspace{1.15cm}
    \end{raggedleft}
  \end{minipage}
  \hspace*{1.7cm}
\end{textblock*}

% make back cover
\begin{textblock*}{\spinepos}(0pt,0pt)
  \noindent\hspace{1.5cm}
  \begin{minipage}[b][\coverheight][b]{.85\spinepos}
    \begin{minipage}[b]{1.7cm}
      \includegraphics[width=1.1cm]{assets/cc.pdf}
      \includegraphics[width=1.1cm]{assets/by.pdf}
      \includegraphics[width=1.1cm]{assets/remix.pdf}
    \end{minipage}
    \hspace{.3cm}
    \begin{minipage}[b]{5cm}
      \begin{raggedright}
        \fontsize{14pt}{16pt}\selectfont\color{white}
      \textit{forall x: Calgary} by P.~D. Magnus et al.\ is
      licensed under a Creative Commons Attribution 4.0 International
      License.\par
      \end{raggedright}

\end{minipage}
\hfill
\vspace*{2cm}
  \end{minipage}
  \hfill
\end{textblock*}

\end{document}
